nlp_architect.data.cdc_resources.relations.word_embedding_relation_extraction.WordEmbeddingRelationExtraction

class nlp_architect.data.cdc_resources.relations.word_embedding_relation_extraction.WordEmbeddingRelationExtraction(method: nlp_architect.data.cdc_resources.relations.relation_types_enums.EmbeddingMethod = <EmbeddingMethod.GLOVE: 'glove'>, glove_file: str = None, elmo_file: str = None, cos_accepted_dist: float = 0.7)[source]
__init__(method: nlp_architect.data.cdc_resources.relations.relation_types_enums.EmbeddingMethod = <EmbeddingMethod.GLOVE: 'glove'>, glove_file: str = None, elmo_file: str = None, cos_accepted_dist: float = 0.7)[source]

Extract Relation between two mentions according to Word Embedding cosine distance

Parameters:
  • method (optional) – EmbeddingMethod.{GLOVE/GLOVE_OFFLINE/ELMO/ELMO_OFFLINE} (default = GLOVE)
  • glove_file (required on GLOVE/GLOVE_OFFLINE mode) – str Location of Glove file
  • elmo_file (required on ELMO_OFFLINE mode) – str Location of Elmo file

Methods

__init__(method, glove_file, elmo_file, …) Extract Relation between two mentions according to Word Embedding cosine distance
extract_all_relations(mention_x, mention_y)
extract_relation(mention_x, mention_y, relation) Base Class Check if Sub class support given relation before executing the sub class
extract_sub_relations(mention_x, mention_y, …) Check if input mentions has the given relation between them
get_supported_relations() Return all supported relations by this class
is_word_embed_match(mention_x, mention_y) Check if input mentions Word Embedding cosine distance below above 0.65
extract_all_relations(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight) → Set[nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType][source]
extract_relation(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight, relation: nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType

Base Class Check if Sub class support given relation before executing the sub class

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
  • relation – RelationType
Returns:

relation in case mentions has given relation and

RelationType.NO_RELATION_FOUND otherwise

Return type:

RelationType

extract_sub_relations(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight, relation: nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has the given relation between them

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
  • relation – RelationType
Returns:

relation in case mentions has given relation or

RelationType.NO_RELATION_FOUND otherwise

Return type:

RelationType

static get_supported_relations() → List[nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType][source]

Return all supported relations by this class

Returns:List[RelationType]
is_word_embed_match(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight)[source]

Check if input mentions Word Embedding cosine distance below above 0.65

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
Returns:

bool